<div class="content-wrapper">
    <section class="content-header">
        <h1>产品列表</h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">系统配置</li>
            <li class="active">产品列表</li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-header with-border">
                <form class="form-inline" action="/item/itemList" method="get">
                    <div class="form-group">
                        <label for="name">项目名称 </label>
                        <input type="text" class="form-control" id="name" name="name" placeholder="项目名称" value="{$name}">
                    </div>
                    <div class="form-group">
                        <label class="label-control" for="parent_cid">一级分类</label>
                        <select id="parent_cid" name="parent_cid" class="form-control">
                            <option value="0">请选择</option>
                            <foreach name="one_cate" item="cate">
                                <option value="{$cate.id}" <if condition="$cate.id eq $parent_cid ">selected</if>>{$cate.name}</option>
                            </foreach>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="label-control" for="second_cid">二级分类</label>
                        <select id="second_cid" name="second_cid" class="form-control">
                            <option value="0">请选择</option>
                            <foreach name="two_cate" item="two">
                                <option value="{$two.id}" <if condition="$two.id eq $second_cid ">selected</if>>{$two.name}</option>
                            </foreach>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="label-control" for="three_cid">三级分类</label>
                        <select id="three_cid" name="three_cid" class="form-control">
                            <option value="0">请选择</option>
                            <foreach name="three_cate" item="three">
                                <option value="{$three.id}" <if condition="$three.id eq $three_cid ">selected</if>>{$three.name}</option>
                            </foreach>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="label-control" for="is_enquiry">询价 </label>
                        <select id="is_enquiry" name="is_enquiry" class="form-control">
                            <option value="0">请选择</option>
                            <option value="1" <if condition="$is_enquiry eq 1">selected</if>>是</option>
                            <option value="2" <if condition="$is_enquiry eq 2">selected</if>>否</option>
                        </select>
                    </div>
                    <button type="submit" class="btn btn-info" id="save-btn">查询</button>
                    <button type="button" class="btn btn-danger" onclick="window.location.href='/item/editItem'">添加</button>
                </form>
            </div>
            <div class="box-body table-responsive">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <th style="width: 80px">ID</th>
                        <th>一级分类</th>
                        <th>二级分类</th>
                        <th>三级分类</th>
                        <th>产品名称</th>
                        <th>投放端口</th>
                        <th>投放位置</th>
                        <th>是否询价</th>
                        <th>状态</th>
                        <th style="width: 100px">操作</th>
                    </tr>
                    <if condition="count($itemList) eq 0"><tr><td class="text-center" colspan="10">暂无数据...</td></tr></if>
                    <foreach name="itemList" item="item">
                        <tr>
                            <td>{$item.id}</td>
                            <td>{$item.parent_name}</td>
                            <td>{$item.second_name}</td>
                            <td>{$item.three_name}</td>
                            <td>{$item.name}</td>
                            <td>{$item.put_port}</td>
                            <td>{$item.put_place}</td>
                            <td>
                                <if condition="$item.is_enquiry eq 1 ">
                                    是
                                    <else />
                                    <span class="text-red">否</span>
                                </if>
                            </td>
                            <td>
                                <if condition="$item.status eq 1 ">
                                    正常
                                    <else />
                                    <span class="text-red">已关闭</span>
                                </if>
                            </td>
                            <td>
                                <button class="btn btn-primary btn-xs" type="button" onclick="window.location.href='/item/editItem?id={$item.id}'">详情</button>&nbsp;
                                <button class="btn bg-maroon btn-xs btn-delete" type="button" data-id="{$item.id}">删除</button>&nbsp;
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
            <div class="box-footer clearfix">{$page_html}</div>
        </div>
    </section>
</div>
<script type="application/javascript">
    $('.btn-delete').click(function () {
        var id = $(this).attr('data-id');
        ArtDialogHlp.showConfirm('提示',"确认删除该产品吗",function () {
            $.post('/admin/item/deleteItem',
                {
                    id : id,
                    status : -5
                }, function(data){
                    if(data.Code == 999) {
                        ArtDialogHlp.showInfo('提示', '操作成功', function(){
                            window.location.href = '/admin/Item/itemList';
                        });
                    } else {
                        ArtDialogHlp.showInfo('提示', data.Msg);
                    }
                }, 'json');
        });
    });
</script>